<%@ page language="java" contentType="text/html; charset=UTF-8"%>
<!DOCTYPE html>
<html>
<head>
<title>任务详情</title>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta name="renderer" content="webkit">

<%@ include file="/WEB-INF/common.jsp"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>
<%@ taglib prefix="sf " uri="http://www.springframework.org/tags/form"%>
<%@ taglib prefix="s " uri="http://www.springframework.org/tags"%>

<link href="${path }/resources/css/plugins/bootstrap-table/bootstrap-table.min.css" rel="stylesheet">
<link href="${path }/resources/css/animate.css" rel="stylesheet">
<link href="${path }/resources/css/style.css?v=4.1.0" rel="stylesheet">
<!--dataTables css样式-->
<link rel="stylesheet" type="text/css"
	href="${path }/resources/css/jquery.dataTables.min.css">
<!--DataTables button扩展-->
<link rel="stylesheet" type="text/css"
	href="${path }/resources/css/buttons.dataTables.min.css">
<link rel="stylesheet" type="text/css"
	href="${path }/resources/css/form.css">



</head>
<body class="gray-bg" style="margin-left:35px">
<jsp:include page="/WEB-INF/loginCheck.jsp" />
	<div>
		<h1 style="margin-left:-10px">测试任务详情</h1>
	</div>
	<hr>
	<!--添加的表单  -->
	<div id="" class="panel-body" style="margin-top: 30px">
		<%-- action="${path }/Enterprise/addEnterPerson.htm" method="post"  --%>
		
		<div class="row">
				<label class="control-label col-md-2 col-sm-2 col-xs-4"
					for="last-name">任务名称:
				</label>
				<div class="col-md-3 col-sm-3 col-xs-6">
					<input  value="${detailContent.name}" readonly="readonly" required="required" class="form-control col-md-7 col-xs-12" required="required">
				</div>
				<label class="control-label col-md-2 col-sm-2 col-xs-4"
					for="last-name">任务类型:
				</label>
				<div class="col-md-3 col-sm-3 col-xs-6">
					<input  value="${detailContent.type}" readonly="readonly" name="department1" required="required" class="form-control col-md-7 col-xs-12" required="required">
				</div>
		</div>
		<div class="row" style="margin-top: 5px">
			<div class="">
				<label class="control-label col-md-2 col-sm-2 col-xs-4"
					for="last-name">项目名称:
				</label>
				<div class="col-md-3 col-sm-3 col-xs-6">
					<input  value="${detailContent.projectName}" readonly="readonly" name="department1" required="required" class="form-control col-md-7 col-xs-12" required="required">
				</div>
			</div>
			<div class="">
				<label class="control-label col-md-2 col-sm-2 col-xs-4"
					for="first-name">任务性质:
				</label>		
	           <div class="col-md-3 col-sm-3 col-xs-6">
					<input  value="${detailContent.character}" readonly="readonly" name="department1" required="required" class="form-control col-md-7 col-xs-12" required="required">
				</div>
			</div>
		</div>
		<div class="row" style="margin-top:5px">
			<div class="">
				<label class="control-label col-md-2 col-sm-2 col-xs-4"
					for="last-name">参与人员:
				</label>
				<div class="col-md-3 col-sm-3 col-xs-6">
					<input  value="${detailContent.paticipant}" readonly="readonly" name="department1" required="required" class="form-control col-md-7 col-xs-12" required="required">
				</div>
			</div>
			<div class="">
				<label class="control-label col-md-2 col-sm-2 col-xs-4"
					for="last-name">任务地点:
				</label>
				<div class="col-md-3 col-sm-3 col-xs-6">
					<input  value="${detailContent.location}" readonly="readonly" name="IDCard1" required="required" class="form-control col-md-7 col-xs-12" required="required">
				</div>
			</div>
		</div>
		<div class="row" style="margin-top:5px">
			<div class="">
				<label class="control-label col-md-2 col-sm-2 col-xs-4"
					for="last-name">任务创建时间:
				</label>
				<div class="col-md-3 col-sm-3 col-xs-6">
					<input type="text" value="${detailContent.createTime}" readonly="readonly" name="position1" required="required" class="form-control col-md-7 col-xs-12" required="required">
				</div>
			</div>
			<div class="">
				<label class="control-label col-md-2 col-sm-2 col-xs-4"
					for="last-name">任务接收时间:
				</label>
				<div class="col-md-3 col-sm-3 col-xs-6">
					<input type="text" value="${detailContent.receiveTime}" readonly="readonly" name="position1" required="required" class="form-control col-md-7 col-xs-12" required="required">
				</div>
			</div>
		</div>

		<div class="row" style="margin-top: 5px">
			<div class="">
				<label class="control-label col-md-2 col-sm-2 col-xs-4"
					for="last-name">任务提交时间:
				</label>
				<div class="col-md-3 col-sm-3 col-xs-6">
					<input type="text" value="${detailContent.submitTime}" readonly="readonly" name="phone_number2" required="required" class="form-control col-md-7 col-xs-12" required="required">
				</div>
			</div>
		</div>
		
		<!--表格  -->
	 	<div class="col-md-12 col-sm-12 col-xs-12" style="margin-top: 30px;margin-left:-15px">
			<table id="checkList" class="table table-bordered table-striped" style="width:100%;">
				<thead>
					<tr>
						<th>设施名称</th>
						<th>维保内容</th>
						<th>测试内容</th>
						<!-- <th>判断结果</th> -->
					</tr>
				</thead>
			 </table>
	   </div>
	   <form id="cForm" action="${path }/MaintenanceTask/saveUpdate.htm" data-parsley-validate class="form-horizontal form-label-left" >
	   <input type ="hidden" value = "${detailContent.id}" name = "id" id="detailId"/>

	   <div class="form-group">
				<label class="control-label col-md-3 col-sm-3 col-xs-12"
					for="last-name">任务附件:
				</label>
				<%-- <div class="col-md-6 col-sm-6 col-xs-12">
					<img id="img" class='min' alt="任务附件" src="${path }/resources/img/a1.jpg">
				</div> --%>
				<div class="col-md-6 col-sm-6 col-xs-12" style="margin-top:10px">
				<%-- <a target="_blank" href="${detailContent.maintenancerPhoto}">查看任务附件</a> --%>
<%--   					<c:if test="${detailContent.maintenancerPhoto==null}">
						<i>未上传附件，无法查看</i>
					</c:if>
					<c:if test="${detailContent.maintenancerPhoto!=null}">
						<a target="_blank" href="${detailContent.maintenancerPhoto}">查看任务附件</a>
					</c:if> --%>
					<c:choose>
					   <c:when test="${detailContent.maintenancerPhoto!=null}">  
     						<a target="_blank" href="${detailContent.maintenancerPhoto}">查看任务附件</a>
					   </c:when>
					   <c:otherwise> 
							     						<i>未上传附件，无法查看</i>
					   </c:otherwise>
					</c:choose>
				</div>
	    </div>
	    <div class="form-group">
				<label class="control-label col-md-3 col-sm-3 col-xs-12"
					for="last-name">审核结果:
				</label>
				<div class="col-md-6 col-sm-6 col-xs-12">
					<select id="identify" class="selectpicker form-control" data-live-search="true" name="status" required="required">
						<option value="审核通过">审核通过</option>
						<option value="审核不通过">审核不通过</option>
					</select>
				</div>
	    </div>
	    <div class="form-group">
				<label class="control-label col-md-3 col-sm-3 col-xs-12"
					for="last-name">审核意见:
				</label>
				<div class="col-md-6 col-sm-6 col-xs-12">
					<input type="text" value="" name="checkOpinion" 
						class="form-control col-md-7 col-xs-12">
				</div>
	    </div>
		<div class="form-group">
			<div class="col-md-6 col-sm-6 col-xs-12 col-md-offset-3" >
				
				<c:choose>
					   <c:when test="${detailContent.maintenancerPhoto!=null}">  
     						<button id="submit" type="submit" class="btn btn-success" >保存</button>
							<a href="${path }/MaintenanceTask/taskList.htm" class="btn btn-primary" style="margin-left:500px;">返回</a>
					   </c:when>
					   <c:otherwise> 
							<button  type="button" class="btn btn-success" >保存</button>
							<i>材料不完整，无法审核</i>
							<br><br>
							<a href="${path }/MaintenanceTask/taskList.htm" class="btn btn-primary">返回</a>     						
					   </c:otherwise>
				</c:choose>
				
			</div>
		</div>
		</form>
	</div>
	<!-- Peity-->
	<script src="${path }/resources/js/plugins/peity/jquery.peity.min.js"></script>
	
	<!-- Bootstrap table-->
	<script src="${path }/resources/js/plugins/bootstrap-table/bootstrap-table.min.js"></script>
	<script src="${path }/resources/js/plugins/bootstrap-table/locale/bootstrap-table-zh-CN.min.js"></script>

	<!-- 自定义js-->
	<script src="${path }/resources/js/content.js?v=1.0.0"></script>
	
	<!-- jQuery Validation plugin javascript-->
    <script src="${path }/resources/js/plugins/validate/jquery.validate.min.js"></script>
    <script src="${path }/resources/js/plugins/validate/messages_zh.min.js"></script>
   
   	<!-- jQuery form  -->
    <script src="${path }/resources/js/jquery.form.min.js"></script>
    
    <!-- layer javascript -->
    <script src="${path }/resources/js/plugins/layer/layer.min.js"></script>
    
    	<!--DataTables 核心 js-->
	<script src="${path }/resources/js/jquery.dataTables.min.js"></script>
	<!--DataTables button扩展-->
	<script
		src="${path }/resources/js/dataTables.buttons.min.js"></script>
    	<!-- datatables日期格式化 -->
	<script src="${path }/resources/js/moment.min.js"></script>
    
    <%-- 任务附件图片展示 -->
     <script>
	$(function(){
		$('#img').click(function(){

		$(this).toggleClass('min');
		$(this).toggleClass('max');
		});
	});
	</script> 
	<!-- 任务附件图片展示 -->
	<script src="${path }/resources/js/imgbox/jquery.imgbox.pack.js"></script>
	<script>
		$("a.zoom-1").imgbox();
	</script> --%>


    <script type="text/javascript">
    var data = ${content};  
   
     //然后 DataTables 这样初始化：
     $('#checkList').DataTable( {
    	 data: data,
     	 language: { 
     		"paginate": {
     	          "processing": "正在处理中。。。"
     	        },
     	      //"sProcessing": "处理中...",  
     	      "sLengthMenu": "显示 _MENU_ 项结果",  
     	      "sZeroRecords": "没有匹配结果",  
     	      "sInfo": "显示第 _START_ 至 _END_ 项结果，共 _TOTAL_ 项",  
     	      "sInfoEmpty": "显示第 0 至 0 项结果，共 0 项",  
     	      "sInfoFiltered": "(由 _MAX_ 项结果过滤)",  
     	      "sInfoPostFix": "",  
     	      "sUrl": "",  
     	      "sEmptyTable": "表中数据为空",  
     	      "sLoadingRecords": "载入中...",  
     	      "sInfoThousands": ",",  
     	      "oPaginate": {  
     	          "sFirst": "首页",  
     	          "sPrevious": "上页",  
     	          "sNext": "下页",  
     	          "sLast": "末页"  
     	      },  
     	      "oAria": {  
     	          "sSortAscending": ": 以升序排列此列",  
     	          "sSortDescending": ": 以降序排列此列"  
     	      }  
     	  }  ,
          "iDisplayLength":15,
      	  "lengthMenu":[10,15,20], 
    	  "columns": [ 
	             { "data": "Name",
	            	 "defaultContent" : "",
	            "orderable": false // 禁用排序
	            },
	             { "data": "testName",
	            	"defaultContent" : "",
	            	"orderable": false // 禁用排序
	             },
                 {
	                  "data": "id",
	                  "orderable": false, // 禁用排序
	                  "defaultContent": "",
	                  "render": function (data, type, row, meta) {
	                	  return data = '<a href="${path }/MaintenanceTask/itemDetail.htm?id=' + data + '" class="btn btn-primary btn-xs"><i class="fa fa-folder"></i>详情</a>';           
	                  }
		   		}/* ,
		   		{ "data": "judgeResult",
	            	 "defaultContent" : "",
	            	 "orderable": false // 禁用排序
	             } */
		   	 
	             ],
     });
	</script>
	<script type="text/javascript">
		var status = $("#identify").find("option:selected").text();
		var checkOpinion = $("#checkOpinion").val();
		var detailId = $("#detailId").val();
		$("#submit").click(function()
		{
			
			$.ajax(
			{
		  		 url: "/firefighting/MaintenanceTask/saveUpdate.htm",
		         dataType:"json",
		         type: "POST",
		         async:"false",
		         data:
		         {
		        	 "status" : status,
				     "checkOpinion" : checkOpinion, 
					 "id" :detailId
		         },
		          //traditional: true,//属性在这里设置
		          //cache: false,
		         success: function (data)
		         {
		        	 //alert("success");
				     var content = data.content;
				     //alert(content);
				     console.log(data.content);
					 if(content=="status")
					 {
					 	alert("任务未全部执行，不能审核！");
					 }
					 else if(content=="unexecuted")
					 {
						alert("任务未全部执行，不能审核！");
					 }
					 else if(content=="checked"){
						 alert("已审核通过，不能再次审核！");
					 }
					 else if(content=="true")
					 {
						 alert("审核成功！");
					 }
					 window.location.href="/firefighting/MaintenanceTask/taskList.htm";
		         },
		         error:function(data)
		         {
		        	 ///alert("data.content = " + data.content);
		        	 console.log(data.content + "2");
		        	 alert("审核失败");
		         }
		     });
		});
</script>


</body>
</html>